<%-- 
    Document   : index
    Created on : 19 Aug, 2011, 4:22:41 PM
    Author     : Vivekananda Moosani
--%>

<%@page contentType="text/html" pageEncoding="windows-1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%
String mode = request.getParameter("mode");
String datasourceName = request.getParameter("datasourceName");
String adminKey = request.getParameter("adminKey");
boolean datasourceValid = true;
boolean submitMode = false;
boolean adminKeyIncorrect = false;
if("submit".equals(mode)) {
    submitMode = true;    
    if(datasourceName == null || datasourceName.trim().length() == 0) {
        datasourceValid = false;
    } else {
        datasourceValid = true;
        if("Hubb!eBubbl6".equals(adminKey)) {
            session.setAttribute("datasourceName", datasourceName);
            adminKeyIncorrect = false;
        } else {
            adminKeyIncorrect = true;
        }
    }
}
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <link rel="SHORTCUT ICON" href="favico.gif"/>
        <title>JSP Page</title>
        <link rel="stylesheet" href="default.css" />
    </head>
    <body>
        <h1>Configure the database settings here to be used for this session</h1>
        <%
        if(submitMode) {
            if(!datasourceValid) {
                %> <b class="ErrorMsg">Datasource name was left empty</b><br/><br/> <%
            } else if(adminKeyIncorrect) {
                %> <b class="ErrorMsg">Incorrect admin key</b><br/><br/> <%
            } else {
                %> <b class="SuccessMsg">Datasource name saved for the session (<%=datasourceName%>)
                    <br/><br/></b>
                    Please visit <a href="DbAdmin.jsp">administration page<br/><br/></a>
                <%
            }
        }%>
        <form method="POST">
            Enter admin key: <input type="text" name="adminKey"/><br/>
            JDBC datasource name: <input type="text" name="datasourceName"/>
            ex:jdbc/appsDB
            <br/>
            <input type="submit" name="mode" value="submit"/>
        </form>
        <br/>
        Note that the datasource name would be remembered for the session

    </body>
</html>
